﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using XiMiBll;
using XiMiModel;
using XiMiModelDto;

namespace XiaoMiAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShopController : ControllerBase
    {
        private readonly ShopBll _shopBll;
        public ShopController(ShopBll shopBll)
        {
            _shopBll = shopBll;
        }
        [HttpPost]
        public IActionResult AddShop(ShopModel shopModel)
        {
            return Ok(_shopBll.AddShop(shopModel));
        }
        [HttpGet]
        public IActionResult Show()
        {
            var totalcount = 0;
            var list = _shopBll.Show(out totalcount);
            return Ok(new {list,totalcount });
        }
        [HttpGet]
        public IActionResult Del(int id)
        {
            return Ok(_shopBll.Del(id));
        }
        [HttpPost]
        public IActionResult AddOrder(OrderFromDto orderFromDto)
        {
            var number ="";
           var list=  _shopBll.AddOrder(orderFromDto,out number);
            return Ok(new { number,list});
        }
        [HttpPost]
        public IActionResult AddCity(AddressModel addressModel)
        {
            return Ok(_shopBll.AddCity(addressModel));
        }
        [HttpGet]
        public IActionResult Check(int id)
        {
            return Ok(_shopBll.Check(id));
        }
        [HttpGet]
        public IActionResult DelAddress(int id)
        {
            return Ok(_shopBll.DelAddress(id));
        }
        [HttpPost]
        public IActionResult Update(AddressModel addressModel)
        {
            return Ok(_shopBll.Update(addressModel));
        }
        [HttpGet]
        public IActionResult BindCity(int id)
        {
            return Ok(_shopBll.BindCity(id));
        }
        [HttpGet]
        public IActionResult ShowAddressDto()
        {
            return Ok(_shopBll.ShowAddressDto());
        }
        [HttpGet]
        public IActionResult Fan(int id)
        {
            return Ok(_shopBll.Fan(id));
        }
    }
}
